package com.company.cloud.club.modules.db.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.company.cloud.club.modules.db.domain.FriendDynamic;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Set;

public interface FriendDynamicMapper extends BaseMapper<FriendDynamic> {

    @Select({
            "<script>",
            "SELECT * FROM club_friend_dynamic ",
            "WHERE user_id IN ",
            "<foreach collection='collList' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "ORDER BY time_created DESC limit #{pageStart}, #{pageEnd}",
            "</script>"
    })
    List<FriendDynamic> selectMyFriend(@Param("collList") Set<String> collList,
                                       @Param("pageStart") Integer pageStart,
                                       @Param("pageEnd") Integer pageEnd);

    @Select({
            "<script>",
            "SELECT count(*) FROM club_friend_dynamic ",
            "WHERE user_id IN ",
            "<foreach collection='collList' item='id' open='(' separator=',' close=')'>",
            "#{id}",
            "</foreach>",
            "</script>"
    })
    int countMyFriend(@Param("collList") Set<String> collList);

}